<template>
	<div>
		<!-- <NavTabs :tabs="navTagList" v-model="activeTag"></NavTabs> -->
		<!-- <div class="btn tr w-100" id="no-print">
			<el-button type="primary" @click="printHtml('print_area')">打印</el-button>
		</div> -->
		<div class="config-content">
			
			<div class="report" :style="{width:nowRowData.approvalStatus ==1 || !nowRowData.approvalStatus?'100%':'65%'}">
				<!-- <ElderStayAllowance id="print_area" v-bind="$attrs" :approvalStatus="nowRowData.approvalStatus" :isDetail="nowRowData.approvalStatus != 2 && nowRowData.approvalStatus !== undefined" :params="nowRowData" :key="tableKey" :otherData="nowRowData" :editData="nowRowData.ofsSubsidyApplyElderlyPO" :editMode="editMode" :isOkApproval="isOkApproval"></ElderStayAllowance> -->
				<ApplyReport
				    ref ="applyReport"
					:creditCode="userInfo.organizationId"
					v-bind="$attrs"
					:approvalStatus="nowRowData.approvalStatus"
					:isDetail="nowRowData.approvalStatus != 2 && nowRowData.approvalStatus !== undefined"
					:list="nowRowData.tableRel"
					:params="nowRowData"
					:nowRowData="nowRowData"
					:otherData="nowRowData" 
					:applyNo="nowRowData.applyNo"
					:editData="nowRowData.ofsSubsidyApplyElderlyPO" 
					:editMode="editMode"
					:key="tableKey"
					:isOkApproval="isOkApproval"
				></ApplyReport>
			</div>
			<slot></slot>
		</div>
	</div>
</template>

<script setup lang="ts">
import { printHtml } from '@/utils/print'
import ApplyReport from '@/views/instOperate/components/ApplyReport/index.vue'
import ElderStayAllowance from '@/views/instOperate/components/ApplyReport/components/fiveTypeElder/ElderStayAllowance.vue'
import { getStore } from '@/utils/store'
import apiMod from '@/apiMod/index'

const props = defineProps<{
	nowRowData: any
	isOkApproval: boolean  // 是否可以审批
}>()

const userInfo = getStore('userInfo') || {}
const activeTag = ref(2)
const params = ref({
	belongDate: props.nowRowData.belongDate,
	subsidyProjectId: props.nowRowData.subsidyProjectId,
	organizationId: userInfo.organizationId,
})

const navTagList = [
	{ label: '机构填报内容（申请表）', value: 2 },
	{ label: '机构填报内容（床位审核表）', value: 4 },
	{ label: '机构申请需要上传的材料', value: 3 },
]
// 判断一下老人户籍所在区和机构户籍所在区是不是一个
let editMode = reactive({
	crAreaSame:true,
	orgCrArea:true,
	elderCrArea:true,
	streetAudit:true,
	assessOrgAudit:true,
	civilAudit:true,
	societyAudit:true
})
let tableKey = ref(0)
watch(()=>props.nowRowData,(val)=>{
	if(val){
		if(val.ofsSubsidyApplyElderlyPO){
				// val.sameArea==1,代表同区，不能编辑
			if(val.ofsSubsidyApplyElderlyPO.sameArea==1){
				editMode.orgCrArea=true
				editMode.elderCrArea=true
			}else if(val.approvalStatus=="2"){
				editMode.orgCrArea=false
				editMode.elderCrArea=false
			}else if(val.ofsSubsidyApplyElderlyPO.sameArea==0){
				editMode.orgCrArea=false
				editMode.elderCrArea=false
			}
			tableKey.value = Math.random()
		}
		
		if(val.approvalStatus!="2"&&val.approvalStatus!='1'){
			// 待提交不可编辑
			editMode.crAreaSame=false
			editMode.orgCrArea=true
			editMode.elderCrArea=true
			editMode.streetAudit=false
			editMode.assessOrgAudit=false
			editMode.civilAudit=false
			editMode.societyAudit = false
			
		}else if(val.approvalStatus=="1"){
			// 待提交不可编辑
			editMode.crAreaSame = true
		}

		
	}
},{
	immediate:true,
	deep:true
})
</script>

<style scoped lang="scss">
.config-content {
	padding: 12px;
	margin-top: 20px;
	border: 1px solid #dcdcdc;
	border-radius: 10px;
  display: flex;
  .report {
    width: 70%;
  }
}
</style>
